package jezyk_java.robert_wolos.wielowatkowa

import java.awt.geom.Ellipse2D;
import java.awt.geom.Rectangle2D;

/**
 * Author: Daniel
 * Date: 08.08.13
 */

public class Ball {
    private static final int XSIZE = 15;
    private static final int YSIZE = 15;

    private double x = 0;
    private double y = 0;
    private double dx = 1;
    private double dy = 1;

    public void move(Rectangle2D bouds) {
        x += dx;
        y += dy;

        if (x < bouds.getMinX()) {
            x = bouds.getMinX();
            dx = -dx;
        }
        if (x + XSIZE >= bouds.getMaxX()) {
            x = bouds.getMaxX() - XSIZE;
            dx = -dx;
        }
        if (y < bouds.getMinY()) {
            y = bouds.getMinY();
            dy = -dy;
        }
        if (y + YSIZE >= bouds.getMaxY()) {
            y = bouds.getMaxY() - YSIZE;
            dy = -dy;
        }
    }

    public Ellipse2D getShape() {
        return new Ellipse2D.Double(x, y, XSIZE, YSIZE);
    }

}
